﻿using System;
using System.Collections.Generic;
using System.Text;
using vJine.Core.ORM;
using System.Xml.Serialization;

namespace vJineCore_QuickStart.BML {
    public partial class MyEntity {
        public class converters {
            public class int_string {
                public static object CONV_I(int V) {
                    return V.ToString();
                }

                public static int CONV_Q(string V) {
                    return int.Parse(V);
                }
            }

            public class myenum_string {
                public static object CONV_I(MyEnum V) {
                    return V.ToString();
                }

                public static MyEnum CONV_Q(string V) {
                    return (MyEnum)Enum.Parse(typeof(MyEnum), V);
                }
            }
        }

        static DateTime dt_stamp = DateTime.Now;

        public MyEntity() {
            this.F_STRING = "Hello World";
            this.F_DATETIME = dt_stamp;
        }
        
        public MyEntity(bool IsMax) {
            if (IsMax) {
                this.InitMax();
            } else {
                this.InitMin();
            }
        }

        [XmlAttribute]
        public bool F_BOOL { get; set; }
        public partial class _ {
            public static readonly
                Property<MyEntity, bool> F_BOOL = new Property<MyEntity, bool>("F_BOOL");
        }

        [XmlAttribute]
        public bool? F_BOOL_NULL { get; set; }
        public partial class _ {
            public static readonly
                Property<MyEntity, bool?> F_BOOL_NULL = new Property<MyEntity, bool?>("F_BOOL_NULL");
        }

        [XmlAttribute]
        public sbyte F_SBYTE { get; set; }
        [XmlAttribute]
        public sbyte? F_SBYTE_NULL { get; set; }

        [XmlAttribute]
        public byte F_BYTE { get; set; }
        [XmlAttribute]
        public byte? F_BYTE_NULL { get; set; }

        [XmlAttribute]
        public short F_SHORT { get; set; }
        [XmlAttribute]
        public short? F_SHORT_NULL { get; set; }

        [XmlAttribute]
        public ushort F_USHORT { get; set; }
        [XmlAttribute]
        public ushort? F_USHORT_NULL { get; set; }

        [XmlAttribute]
        public int F_INT { get; set; }
        [XmlAttribute]
        public int? F_INT_NULL { get; set; }

        [XmlAttribute]
        public uint F_UINT { get; set; }
        [XmlAttribute]
        public uint? F_UINT_NULL { get; set; }

        [XmlAttribute]
        public long F_LONG { get; set; }
        [XmlAttribute]
        public long? F_LONG_NULL { get; set; }

        [XmlAttribute]
        public ulong F_ULONG { get; set; }
        [XmlAttribute]
        public ulong? F_ULONG_NULL { get; set; }

        [XmlAttribute]
        public float F_FLOAT { get; set; }
        [XmlAttribute]
        public float? F_FLOAT_NULL { get; set; }

        [XmlAttribute]
        public double F_DOUBLE { get; set; }
        [XmlAttribute]
        public double? F_DOUBLE_NULL { get; set; }

        [XmlAttribute]
        public decimal F_DECIMAL { get; set; }
        [XmlAttribute]
        public decimal? F_DECIMAL_NULL { get; set; }

        [XmlAttribute]
        public char F_CHAR { get; set; }
        [XmlAttribute]
        public char? F_CHAR_NULL { get; set; }

        [XmlAttribute]
        public string F_STRING { get; set; }

        [XmlAttribute, Map(IsNullable=true)]
        public string F_STRING_NULL { get; set; }
        [XmlAttribute, Map(IsNullable = true)]
        public string F_STRING_NULL2 { get; set; }

        [XmlAttribute]
        public DateTime F_DATETIME { get; set; }
        [XmlAttribute]
        public DateTime? F_DATETIME_NULL { get; set; }

        [XmlAttribute]
        public MyEnum F_ENUM { get; set; }
        [XmlAttribute]
        public MyEnum? F_ENUM_NULL { get; set; }

        [XmlAttribute]
        public Guid F_GUID { get; set; }
        [XmlAttribute]
        public Guid? F_GUID_NULL { get; set; }

        [XmlAttribute]
        public int F_INT2 { get; set; }
        [XmlAttribute]
        public int? F_INT2_NULL { get; set; }
        [XmlAttribute]
        public MyEnum F_ENUM2 { get; set; }
        [XmlAttribute]
        public MyEnum? F_ENUM2_NULL { get; set; }

        [XmlAttribute, Map(IsNullable=true)]
        public byte[] F_BYTES { get; set; }
    }

    public partial class MyEntity {

        void InitMax() {
            this.F_BOOL = true;
            this.F_BOOL_NULL = true;
            this.F_SBYTE = sbyte.MaxValue;
            this.F_SBYTE_NULL = sbyte.MaxValue;
            this.F_BYTE = byte.MaxValue;
            this.F_BYTE_NULL = byte.MaxValue;
            this.F_SHORT = short.MaxValue;
            this.F_SHORT_NULL = short.MaxValue;
            this.F_USHORT = ushort.MaxValue;
            this.F_USHORT_NULL = ushort.MaxValue;
            this.F_INT = int.MaxValue;
            this.F_INT_NULL = int.MaxValue;

            this.F_UINT = uint.MaxValue;
            this.F_UINT_NULL = uint.MaxValue;
            this.F_LONG = long.MaxValue;
            this.F_LONG_NULL = long.MaxValue;

            //this.F_FLOAT = float.MaxValue;
            //this.F_FLOAT_NULL = float.MaxValue;
            //this.F_DOUBLE = double.MaxValue;
            //this.F_DOUBLE_NULL = double.MaxValue;
            //this.F_DECIMAL = decimal.MaxValue;
            //this.F_DECIMAL_NULL = decimal.MaxValue;

            this.F_CHAR = 'A';
            this.F_STRING =
                "12345678901234567890123456789012345678901234567890";
            this.F_STRING_NULL =
                "12345678901234567890123456789012345678901234567890";
            this.F_DATETIME = DateTime.Now;
            this.F_DATETIME_NULL = DateTime.Now;

            this.F_ENUM = MyEnum.Default;
            this.F_ENUM_NULL = null;

            this.F_INT2 = int.MaxValue;
            this.F_INT2_NULL = int.MaxValue;
            this.F_ENUM2 = MyEnum.World | MyEnum.Hello;
            this.F_ENUM2_NULL = MyEnum.Default;

            this.F_GUID = Guid.NewGuid();
            this.F_GUID_NULL = Guid.NewGuid();

            this.F_BYTES = new byte[] { 0x01, 0x02, 0x03 };
        }

        void InitMin() {
            this.F_BOOL = false;
            this.F_BOOL_NULL = null;
            this.F_SBYTE = sbyte.MaxValue;
            this.F_SBYTE_NULL = null;
            this.F_BYTE = byte.MinValue;
            this.F_BYTE_NULL = null;
            this.F_SHORT = short.MinValue;
            this.F_SHORT_NULL = null;
            this.F_USHORT = ushort.MinValue;
            this.F_USHORT_NULL = null;
            this.F_INT = int.MinValue;
            this.F_INT_NULL = null;
            
            this.F_UINT = uint.MinValue;
            this.F_UINT_NULL = null;
            this.F_LONG = long.MinValue;
            this.F_LONG_NULL = null;

            //this.F_FLOAT = float.MinValue;
            //this.F_FLOAT_NULL = null;
            //this.F_DOUBLE = double.MinValue;
            //this.F_DOUBLE_NULL = null;
            //this.F_DECIMAL = decimal.MinValue;
            //this.F_DECIMAL_NULL = null;

            this.F_CHAR = 'B';
            this.F_STRING = "Empty String Not Allowed In Oracle";
            this.F_STRING_NULL = null;
            this.F_DATETIME = DateTime.Now;
            this.F_DATETIME_NULL = null;

            this.F_ENUM = MyEnum.Hello | MyEnum.World;
            this.F_ENUM_NULL = MyEnum.Hello | MyEnum.World;

            this.F_INT2 = int.MinValue;
            this.F_INT2_NULL = null;
            this.F_ENUM2 = MyEnum.Default;
            this.F_ENUM2_NULL = null;

            this.F_GUID = Guid.NewGuid();
            this.F_GUID_NULL = null;
        }
    }
}
